<%@ page import="com.cuit.pojo.Order" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cuit.pojo.Patient" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>

<html>
<head>
    <title>预约结果</title>
    <style type="text/css">
        nav {
            height: 50px;
            background-color: #39bebe;
        }
        nav {
            display: block;
        }
        .nav_right {
            position: absolute;
            right: 50px;
            top: 5px;
        }
        nav .a1 {
            display: block;
            height: 50px;
            position: absolute;
            left: 20px;
            line-height: 50px;
        }
        nav .a2 {
            display: block;
            height: 50px;
            position: absolute;
            left: 90px;
            line-height: 50px;
        }
        .nav_photo {
            border-radius: 50%;
            height: 40px;
            width: 40px;
            position: relative;
            top:10px;
        }

        table{
            border-collapse:collapse;
            border: 1px solid black;

        }
        table td,th{
            border-collapse:collapse;
            margin: 80px auto 10px auto;
            border: 1px solid black;
        }
    </style>
    <script src="../../static/js/jquery-3.3.1.min.js" ></script>
</head>
<body>
<nav>
        <a href="../../patient/appointment.jsp" class="a1">挂号预约 /</a><a href="../../patient/personal_center2.jsp" class="a2">&nbsp;&nbsp;个人中心</a>
        <div class="nav_right">
            <img src="../../patient/images/2.jpg" class="nav_photo">
            <span id="p_id" style="color: #ffffff">${sessionScope.patient.p_id}</span>
        </div>
</nav>

<center>
    <h1>预约情况</h1>
    <table width="400px">
        <tr >
            <th>编号</th>
            <th>病人</th>
            <th>医生</th>
            <th>预约时间</th>
            <th>星期</th>
            <th></th>
        </tr>
        <div id="Info">
            <%
                HttpSession se = request.getSession();
                List<Order> orders = (List<Order>) se.getAttribute("orderInfo");
                String str="orderInfo";
                String str1=null;
                int i=1;
                for(Order order:orders){
                    str1=str+i;
                    se.setAttribute(str1, order);
            %>
            <tr>
                <td id="number"><%=i%></td>
                <td><%=order.getPatient()%></td>
                <td><%=order.getDoctor()%></td>
                <td><%=order.getTime()%></td>
                <td>星期<%=order.getDay()%></td>
                <td><input type="button" value="取消预约<%=i%>"></td>
            </tr>

            <%
                    i++;
                }
            %>
        </div>

    </table>
</center>

<script type="text/javascript" >
    var route="../../checkAllOrder";
    $(function (){
        $("input").click(function(){
            if(window.confirm("请确认删除预约信息")){
                var str=$(this).val();
                var number1=str.charAt(4);
                $.ajax({
                    type:"post",
                    url:"../../deleteOneOrder",
                    data:JSON.stringify(number1),
                    dataType:"text",
                    success:function (data){
                        window.location.replace(route);
                    }
                })

            }

        })
    })

</script>
</body>
</html>
